package com.whfc.openapi.api.fvs.controller;

import com.whfc.common.result.ListData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.fuum.dto.open.OpenApiClientDTO;
import com.whfc.fvs.dto.FvsStreamDTO;
import com.whfc.fvs.dto.FvsTokenDTO;
import com.whfc.fvs.dto.FvsVideoDTO;
import com.whfc.fvs.service.FvsDeviceService;
import com.whfc.openapi.constant.OpenApiConst;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2020/9/8 18:46
 */
@RestController
@RequestMapping("/open/api/v1/fvs")
public class OpenApiFvsController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @DubboReference(interfaceClass = FvsDeviceService.class, version = "1.0.0")
    private FvsDeviceService fvsDeviceService;

    @GetMapping("/token")
    public Result videoList(@RequestAttribute(OpenApiConst.OPENAPI_CLIENT) OpenApiClientDTO openApiClientDTO,
                            @RequestParam("platform") Integer platform) {
        logger.info("查询项目视频token,deptId:{},platform:{}", openApiClientDTO.getDeptId(), platform);
        FvsTokenDTO token = fvsDeviceService.getToken(openApiClientDTO.getDeptId(), platform);
        return ResultUtil.success(token);
    }

    /**
     * 视频监控列表
     *
     * @return
     */
    @GetMapping("/video/list")
    public Result videoList(@RequestAttribute(OpenApiConst.OPENAPI_CLIENT) OpenApiClientDTO openApiClientDTO) {
        logger.info("查询项目视频监控列表,deptId:{}", openApiClientDTO.getDeptId());
        List<FvsStreamDTO> list = fvsDeviceService.getVideoList1(openApiClientDTO.getDeptId());
        return ResultUtil.success(new ListData<>(list));
    }

    /**
     * 澳氹四桥 - 视频监控列表
     *
     * @return
     */
    @GetMapping("/adsq/video/list")
    public List<FvsVideoDTO> adsqVideoList(@RequestAttribute(OpenApiConst.OPENAPI_CLIENT) OpenApiClientDTO openApiClientDTO) {
        logger.info("澳氹四桥-视频监控列表,deptId:{}", openApiClientDTO.getDeptId());
        return fvsDeviceService.getVideoList(openApiClientDTO.getDeptId());
    }

}
